package dj.tic;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;

import dj.engine.panel.Button3D;
import dj.engine.screen.ProportionalLayout;
import dj.engine.screen.Screen;
import dj.engine.util.Vec2f;
import dj.engine.util.Vec2i;

public class TicTitleScreen extends Screen{
	private Button3D startButton;
	private Button3D quitButton;
	private final TicApplication parent;
	public TicTitleScreen(TicApplication parent)
	{
		final TicTitleScreen self = this;
		this.parent = parent;
		startButton = new Button3D(new Vec2f(100,100), new Vec2f(0,0), Color.GREEN, "Start")
		{
			@Override
			public void onMouseClicked(MouseEvent e) {
				if(this.isPointIntersect(new Vec2i(e.getX(), e.getY())))
				{
					self.parent.startGame();
				}
			}
		};
		quitButton = new Button3D(new Vec2f(100,100), new Vec2f(0, 0), Color.RED, "Quit")
		{
			@Override
			public void onMouseClicked(MouseEvent e) {
				if(this.isPointIntersect(new Vec2i(e.getX(), e.getY())))
				{
					self.parent.shutdown();
					System.exit(0);
				}
			}
		};
		this.layout = new ProportionalLayout();
		layout.add(startButton, ProportionalLayout.FIXED_PROPORTIONS, new Float(.2), new Float(.3));
		layout.add(quitButton, ProportionalLayout.FIXED_PROPORTIONS, new Float(.2), new Float(.6));
	}
	@Override
	public boolean isTransparent() {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public void onTick(long nanosSincePreviousTick) {
		// TODO Auto-generated method stub

	}
	@Override
	public void onDraw(Graphics2D g) {
		// TODO Auto-generated method stub
		g.fillRect(0,0,this.getWidth(), this.getHeight());
		startButton.onDraw(g);
		quitButton.onDraw(g);
		
	}
	@Override
	public void onKeyTyped(KeyEvent e) {
		// TODO Auto-generated method stub

	}
	@Override
	public void onKeyPressed(KeyEvent e) {
		// TODO Auto-generated method stub

	}
	@Override
	public void onKeyReleased(KeyEvent e) {
		// TODO Auto-generated method stub

	}
	@Override
	public void onMouseClicked(MouseEvent e) {
		// TODO Auto-generated method stub
		startButton.onMouseClicked(e);
		quitButton.onMouseClicked(e);
		

	}
	@Override
	public void onMousePressed(MouseEvent e) {
		// TODO Auto-generated method stub

	}
	@Override
	public void onMouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub

	}
	@Override
	public void onMouseDragged(MouseEvent e) {
		// TODO Auto-generated method stub

	}
	@Override
	public void onMouseMoved(MouseEvent e) {
		// TODO Auto-generated method stub

	}
	@Override
	public void onMouseWheelMoved(MouseWheelEvent e) {
		// TODO Auto-generated method stub

	}

}
